package xyz.scootaloo.draft.demo;

import java.util.Optional;
import java.util.function.Predicate;

/**
 * @author flutterdash@qq.com
 * @since 2021/5/8 15:00
 */
public class ExceptionDemo {

    public static void main(String[] args) {
        try {
            new 框架().执行功能(() -> {
                throw new RuntimeException("模拟IO异常");
            });
        } catch (Exception e) {
            // 用户处理异常
        }
    }

    static class 框架 {

        public void 执行功能(功能 用户代码) throws Exception {
            try {
                用户代码.运行();
            } catch (Exception e) {
                // 处理异常, 并抛出
                e.printStackTrace();
                throw e;
            }
        }

    }

    interface 功能 {
        boolean 运行() throws Exception;
    }

}
